package com.myplans.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.Window.Location;
import com.google.gwt.user.client.ui.RootPanel;
import com.myplans.client.view.BaseView;

public class MyPlansEntryPoint implements EntryPoint {
	
	AppController appController = new AppController();
	BaseView baseView = new BaseView();

	@Override
	public void onModuleLoad() {
		UserUtil.code = Location.getParameter("code");
        final String error = Location.getParameter("error_reason");
 
        if (null != error && error.equals("user_denied")) {
           Window.alert("User denied");
//        } 
//        else if (authToken == null || "".equals(authToken)) {
//        	 Location.replace(FacebookUtil.getAuthorizeUrl());
        } else {
//            messageBox = MessageBox.wait("Famousity", "", "Analyzing friend rankings...");
// 
//            facebookService.login(authToken, new AsyncCallback<String>() {
//                public void onFailure(final Throwable caught) {
//                    handleError(caught);
//                }
// 
//                public void onSuccess(final String authToken) {
//                    rankFriends(authToken);
//                }
//            });
        	RootPanel.get().add(baseView);
        	appController.go(baseView);
        	History.newItem("home");
        }
	}

}
